<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    protected function success($data = [], $message = "OK", $code = 200)
    {
        return json_encode([
            'success'   => true,
            'data'      => $data,
            'message'   => $message,
            'code'      => $code
        ]);
    }

    protected function error($message = "操作失败", $code = -1)
    {
        return json_encode([
            'success'   => false,
            'data'      => [],
            'message'   => $message,
            'code'      => $code
        ]);
    }
}
